# Python 2.6.4
# Project Euler, Problem 36
# Copyright 2010 Talha Zaman

def binstr(n):
    bs = ""
    while n>0:
        if n%2: bs = "1" + bs
        else: bs = "0" + bs
        n>>=1
    return bs

total = 0
for i in range(1, 1000000, 2):
    dec, bin = str(i), binstr(i)
    if dec==dec[::-1] and bin==bin[::-1]: total += i

print total
